# flake8: noqa
import os
import platform
from pathlib import Path
from wex.common import *


BASE_DIR = Path(__file__).resolve().parent.parent.parent
MEDIA_URL = "/media/"
# 上传文件存放地址
MEDIA_ROOT = os.path.join(BASE_DIR, "media")

DEBUG = False

# 数据库配置，可以配置多个
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'POOL_OPTIONS': {
            'POOL_SIZE': 10,
            'MAX_OVERFLOW': 10,
            'RECYCLE': 60 * 60
        },
        'NAME': 'wex',
        'USER': 'root',
        'PASSWORD': 'root',
        'HOST': '127.0.0.1',
        'PORT': '3306',
    }
}

# 缓存配置
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": 'redis://127.0.0.1:6379/1',
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
        }
    }
}

# 异步任务celery中间件配置
CELERY_BROKER_URL = 'redis://127.0.0.1:6379/11'

# 后端服务域名
HOST = ''

# 前端域名
WEBSITE_URL = ''

# 插件代码存放地址
PLUGIN_REPO_DIR = os.path.join(BASE_DIR, "plugins")

WWEXX_SERVER = 'https://www.wwexx.net'

# 部署脚本命令
if platform.system().lower().startswith('windows'):
    FRONTEND_DEPLOY_COMMAND = ["bash", os.path.join(BASE_DIR, "scripts", 'linux', 'wex-frontend.sh')]
    BACKEND_DEPLOY_COMMAND = ["bash", os.path.join(BASE_DIR, "scripts", 'linux', 'wex-backend.sh')]
else:
    FRONTEND_DEPLOY_COMMAND = ["powershell", "-File", os.path.join(BASE_DIR, "scripts", 'windows', 'wex-frontend.ps1')]
    BACKEND_DEPLOY_COMMAND = ["powershell", "-File", os.path.join(BASE_DIR, "scripts", 'windows', 'wex-backend.ps1')]

try:
    from wex.env import *
except:
    pass
